<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/index.css" rel="stylesheet">
    <link href="icon/iconfont.css" rel="stylesheet">
    <script src="js/jquery-3.2.1.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/index.js"></script>
    <script src="js/plug-in.min.js"></script>
    <script src="js/jquery.qrcode.min.js"></script>
    <style>
        a:focus {
            text-decoration: none
        }

        a:hover {
            text-decoration: none;
        }

        .iconfont {
            color: #202e43;
        }

        .iconfont:hover {
            color: #0e161d;
        }

        .coments {
            position: relative;
        }

        .coment {
            margin: 0 auto;
        }

        .ulFooter li {
            width: 80px;
            float: left;
        }

        .ulKaoShi2 {
            border: solid 1px rgba(170, 175, 191, 0.82);
            width: 310px;
            position: relative;
            height: 200px;
        }

        .ulKaoShi2 a {
            color: #5f5f5f;
            font-size: 14px;
        }

        .xueChe .iconfont {
            font-size: 60px;
        }

        .dropdown-menu {
            margin: 0;
            padding: 0;
            border: 1px solid #000;
            background: #2f2f2f;
            min-width: 100px;
            height: 55px;
        }

        .dropdown-menu > li {
            width: 100px;
            border-radius: 4px;
        }

        .dropdown-menu > li a {
            color: #9a9a98;
            width: 100px;
            border-radius: 4px;
        }

        .dropdown-menu > li a:hover {
            background: #000000;
            color: white;
            border-radius: 4px;
        }
        .fixediv{position:fixed;top:140px;z-index:9999;width:120px;height:216px;background: rgba(221, 221, 221, 0.07);}
        .fixediv img{float:left;}
        .fixediv a.close{display:block;width:20px;font-size:14px;color:#5e5e5e;text-decoration:none;text-align:center;}
        /*.leftadv{left:0px;}*/
        .rightadv{right:20px;}
    </style>
</head>
<body>
<!--导航-->
<nav class="navbar navbar-inverse navbar-fixed-top navtop">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" data-toggle="collapse"
                    data-target="#response-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="backHome" class="">
                <!--<strong>BY一考通</strong>-->
                <img src="images/LOGO_03.png" alt="LOGO" width="100px" style="display: block;line-height:90px;">
            </a>
        </div>
        <div class="collapse navbar-collapse" id="response-collapse">
            <ul class="nav navbar-nav ulDaoHang" id="nav">
                <li class="itemdisplay" style="display: none"><a href="toaddItem">添加试题</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="mockExam">模拟考试
                        <span class="caret">
                                </span>
                    </a>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="mockExam">科目一</a></li>
                        <li><a href="mockExam4">科目四</a></li>
                    </ul>
                </li>
                <li><a href="practice">随机练习</a></li>
                <li><a href="practice2">顺序练习</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="">针对练习
                        <span class="caret">
                                </span>
                    </a>
                    <ul class="dropdown-menu" role="menu" style="height:105px; ">
                        <li><a href="toForPractice?role=3">图片题</a></li>
                        <li><a href="toForPractice?role=2">文字题</a></li>
                        <li><a href="toForPractice?role=1">选择题</a></li>
                        <li><a href="toForPractice?role=0">判断题</a></li>
                    </ul>
                </li>
            </ul>
            <div class="profile navbar-right">
                <ul class="nav navbar-nav">
                    <li class="nowuser" style="display: none;"><a href="#" id="loginOut">退出当前用户:</a></li>
                    <li><a href="displayUser" class="usernamedisplay"></a></li>
                    <li class="displaylogin"><a href="#" data-toggle="modal"
                                                data-target="#login-modal">登录</a></li>
                    <li class="displaylogin"><a href="#" data-toggle="modal"
                                                data-target="#register-modal">注册</a></li>
                </ul>
            </div>
        </div>
    </div>
</nav>
<!--coments-->
<div class="coments">
    <div class="coment container">
        <div class="container text-center">
            <h3 style="color: #1f1f1f;margin-bottom: 20px;margin-top: 70px;">重庆<span class="time"></span>小车理论考试</h3>
        </div>
        <div class="ulSkills container row" style="margin-top: 20px;">
            <span class="list-group-item-heading col-md-6 col-sm-12" style=" font-size: 20px;
            font-weight: bold;">考试技巧</span>
            <ul class="list-group list-unstyled col-md-8 col-xs-12 ">
                <li class="list-group-item">答题中所有题原则——“安全”，所以怎么做安全就怎么做；</li>
                <li class="list-group-item">遇到紧急情况所有过激的行为都错的，比如急踩（用力踏）油门（制动），急转方向，类似的答案都错；</li>
                <li class="list-group-item"> 能让行的都让行，能帮助的都帮助，能避让就避让，不抢、不急都是对；</li>
                <li class="list-group-item">抢救伤员原则先救人，救人原则先止血；</li>
                <li class="list-group-item">无标志无灯无警路口，优先通过顺序为直-左-右，避让反之；</li>
                <li class="list-group-item">车辆变换位置都要开转向灯，唯一一个不开的就是进环岛（转盘），出环岛也需要打灯；</li>
                <li class="list-group-item">红色是禁令（禁止）、黄色是警告、蓝色是指示，三种颜色都没有是辅助；</li>
                <li class="list-group-item">禁令对禁止、警告对警告、指示对指示，相同就对，不相同就错。</li>
                <li class="list-group-item">远光灯、近光灯的考题只能使用近光灯，不准使用远光灯。</li>
                <li class="list-group-item">黄灯亮与黄灯闪烁只一字之差，“闪烁”确保安全，“亮”不准通行，但如果已越线的可通行。</li>
            </ul>

            <div class=" col-md-4 col-xs-6 ulKaoShi2" style="line-height: 50px;margin-top: 10px">
                <b class="" style="font-size: 20px;text-align: center">重庆2019小车理论考试科目一</b><br>
                <a class=""
                   style="line-height: 40px;text-align: center;width: 130px;height: 40px;background: rgba(221,205,226,0.22);margin-left: 20px">
                    <a href="#">
                        <span class="icon iconfont icon-zaixiankaoshi"
                              style="font-size: 25px;position: absolute;top: 50px;left:28px"></span>
                        <span style="margin-left: 30px;">
                             <a href="practice2">顺讯练习</a>
                        </span>
                    </a>
                </a>
                <a class=""
                   style="line-height: 30px;text-align: center;width: 130px;height: 40px;background: rgba(221,205,226,0.22);margin-left: 20px">
                    <a href="#">
                        <span class="icon iconfont icon-kaoshi1"
                              style="font-size: 30px;position: absolute;top: 50px;left:150px"></span>
                        <span style="margin-left: 40px;">
                             <a href="practice">随机练习</a>
                        </span>
                    </a>
                </a>
                <span class="wrongItem"
                      style=";text-align: center;width: 130px;height: 40px;margin-left: 20px">
                    <a href="#">
                        <span class="icon iconfont icon-tubiaozhizuomoban"
                              style="font-size: 30px;position: absolute;top: 103px;left:28px"></span>
                        <span style="margin-left: 30px;">
                             <a href="toWrongPractice">错题练习</a>
                        </span>
                    </a>
                </span>
                <br>
                <a href="mockExam">
                <button class="btn btn-group btn-info list-group-item-info list-group-item" style="text-align: center;">
                    模拟考试</button></a>
            </div>

            <div class=" col-md-4 col-xs-6 ulKaoShi2" style="line-height: 50px;margin-top: 10px">
                <b class="" style="font-size: 20px;text-align: center">重庆2019小车理论考试科目四</b><br>
                <a class=""
                   style="line-height: 40px;text-align: center;width: 130px;height: 40px;background: rgba(221,205,226,0.22);margin-left: 20px">
                    <a href="#">
                        <span class="icon iconfont icon-zaixiankaoshi"
                              style="font-size: 25px;position: absolute;top: 50px;left:28px"></span>
                        <span style="margin-left: 30px;">
                             <a href="practice2">顺讯练习</a>
                        </span>
                    </a>
                </a>
                <a class=""
                   style="line-height: 30px;text-align: center;width: 130px;height: 40px;margin-left: 20px">
                    <a href="#">
                        <span class="icon iconfont icon-kaoshi1"
                              style="font-size: 30px;position: absolute;top: 50px;left:150px"></span>
                        <span style="margin-left: 40px;">
                             <a href="practice">随机练习</a>
                        </span>
                    </a>
                </a>
                <span class="wrongItem"
                      style=";text-align: center;width: 130px;height: 40px;margin-left: 20px">
                    <a href="#">
                        <span class="icon iconfont icon-tubiaozhizuomoban"
                              style="font-size: 30px;position: absolute;top: 103px;left:28px"></span>
                        <span style="margin-left: 30px;">
                             <a href="toWrongPractice">错题练习</a>
                        </span>
                    </a>
                </span>
                <br>
                <a href="mockExam4">
                <button class="btn btn-group btn-info list-group-item-info list-group-item" style="text-align: center;">
                    模拟考试</button></a>
            </div>

            <div class="xueChe col-xs-12 col-md-12" style="margin-bottom: 40px;">
                <h3 class="text-center">学车流程</h3>
                <div class="col-md-2 col-xs-4 text-center">
                    <span class="iconfont icon-che1"></span>
                    <br>
                    <h3>找驾校</h3>
                </div>
                <div class="col-md-2 col-xs-4 text-center">
                    <span class="iconfont icon-icon-kaoshijilu"></span>
                    <br>
                    <h3>科目一</h3>
                </div>
                <div class="col-md-2 col-xs-4 text-center">
                    <span class="iconfont icon-cheliang"></span>
                    <br>
                    <h3>科目二</h3>
                </div>
                <div class="col-md-2 col-xs-4 text-center">
                    <span class="iconfont icon-chepai"></span>
                    <br>
                    <h3>科目三</h3>
                </div>
                <div class="col-md-2 col-xs-4 text-center">
                    <span class="iconfont icon-zaixiankaoshi"></span>
                    <br>
                    <h3>科目四</h3>
                </div>
                <div class="col-md-2 col-xs-4 text-center">
                    <span class="iconfont icon-jiashizhengzhuanru"></span>
                    <br>
                    <h3>拿本</h3>
                </div>
            </div>
        </div>
    </div>
</div>
<!--fotter-->
<footer style="background: #000;">
    <div class="container">
        <div class="agile-footer-grids container" style="color: #7f7f7f;">
            <div class="col-md-4 agile-footer-grid">
                <p></p>
                <span style="color: #fff">关于</span>&nbsp;<span
                    style="color: #3e8efb;font-size: 16px;font-family: '微软雅黑'">BY一考通</span>
                <div class="agile-footer-info">
                    <p style="color: #7f7f7f">BY一考通是一个可以免费在线刷题、练习、模拟考试的驾考模拟考试系统，用户登录后即可记录错题，考试完成生成成绩，计算考试合格率等。</p>
                    <h5 style="color: #7f7f7f">在此订阅</h5>
                    <form action="#" method="post">
                        <input type="email" name="Email" placeholder="Email" required="">
                        <input type="submit" class="" value="提交">
                    </form>
                </div>
            </div>
            <div class="col-md-4 agile-footer-grid">
                <p></p>
                <b style="color: #fff;font-size: 16px;">热门驾校</b>
                <div class="agile-post-grids">
                    <div class="agile-post-grid">
                        <div class="col-md-5 agile-post-left">
                            <a href="#">
                                <img src="images/xiexin.png" alt="" width="80px;">
                            </a>
                        </div>
                        <div class="col-md-7 agile-post-right">
                            <h5><a href="#" style="color:#fff;">重庆协信驾校</a></h5>
                            <p><i class="fa fa-calendar-o" aria-hidden="true">
                            </i> 驾校地址：重庆市巴南区八公里协信车时光内</p>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="agile-post-grid">
                        <div class="col-md-5 agile-post-left">
                            <a href="#">
                                <img src="images/chichen.png" alt="" width="80px;">
                            </a>
                        </div>
                        <div class="col-md-7 agile-post-right">
                            <h5><a href="#" style="color:#fff;">重庆驰晨驾校</a></h5>
                            <p><i class="fa fa-calendar-o" aria-hidden="true"></i> 驾校地址：重庆市重庆市渝北区G5001(空港互通)</p>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
            <div class="col-md-4 agile-footer-grid">
                <p></p>
                <b style="color: #ffffff;font-size: 16px;">联系我们</b>
                <div class="popular-grids">
                    <div class="popular-grid" style="margin-top: 10px;">
                        <b href="#" class="text-center"><img src="images/weixin.jpg" width="100px;">
                            <p></p>扫一扫，加我微信</b>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</footer>
<!--登录-->
<div class="modal fade login-modal" id="login-modal" tabindex="-1">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">&times;</button>
                <h4>
                    <b>用户登录</b>
                </h4>
            </div>
            <div class="modal-body">
                <div>
                    <!--<form method="post">-->
                    <div class="form-group">
                        <label for="username">Username <span
                                class="glyphicon glyphicon-user"></span> <input type="text"
                                                                                name="username" class="form-control"
                                                                                id="username"
                                                                                placeholder="输入用户名"
                                                                                style="padding-left: 22px"></label>
                    </div>
                    <div class="form-group">
                        <label for="password">Password <span
                                class="glyphicon glyphicon-lock"></span> <input type="password"
                                                                                name="password" class="form-control"
                                                                                id="password"
                                                                                placeholder="输入密码"
                                                                                style="padding-left: 22px"></label>
                    </div>
                    <div class="modal-footer">
                        <input type="submit" class="btn btn-group-xs" id="userLogin" style="color: white" value="登录">
                        <!--<button onclick="loginUser()" class="btn btn-group-xs">login</button>-->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--注册-->
<div class="modal fade login-modal" id="register-modal" tabindex="-1">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">&times;</button>
                <h4>
                    <b>用户注册</b>
                </h4>
            </div>
            <div class="modal-body">
                <div id="form2">
                    <div class="form-group">
                        <label for="username">Username<span
                                class="glyphicon glyphicon-user"></span> <input type="text"
                                                                                name="username" class="form-control"
                                                                                id="rusername"
                                                                                placeholder="输入用户名"
                                                                                style="padding-left: 22px"></label>
                        <br><i id="iusername" style="position: absolute;top:70px;"></i>
                    </div>
                    <div class="form-group">
                    <label for="password">Password <span
                            class="glyphicon glyphicon-lock"></span>
                        <input type="password"
                               name="password" class="form-control"
                               id="rpassword"
                               placeholder="输入密码"
                               style="padding-left: 22px"></label>
                </div>
                    <div class="form-group">
                        <label for="remail">Email
                            <span style="position: absolute;top: 192px;left: 20px;" class="glyphicon glyphicon-envelope"></span>
                            <input type="email"
                                   name="email" class="form-control"
                                   id="remail"
                                   placeholder="输入邮箱"
                                   style="padding-left: 22px">
                        </label>
                        <p></p>
                        <input type="hidden" id="yanzhengma-hidden">
                        <input class="btn-sm"  placeholder="输入验证码" style="border: silver;height: 35px;" type="text" id="YanZhengMa">
                        <input type="button" value="获取验证码" class="btn btn-info btn-sm" id="GetYanZhengMa"></input>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-group-xs" style="color: white" id="userRegister">注册
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--扫码-->
<div id="fixediv" class="fixediv rightadv text-center hidden-xs" style="height:260px;border: 1px solid #b6b8b7;background: #f1f1f1; border-radius: 6%;">
    <a class="close" style="font-size: 18px;color: #f00">x</a><br>
    <span style="font-size: 14px;color: rgba(142,142,143,0.97);">扫码考试</span><p></p>
    <div id="qrcode" style="margin-bottom: 5px;"></div>
    <a href="#" class="weixin"><span class="iconfont icon-weixin" style="font-size:18px;padding: 5px;color: green "></span>关注微信</a><p></p>
    <a href="#" class="weibo"><span class="iconfont icon-xinlangweibo" style="font-size:16px;padding: 5px;color: red "></span>关注微博</a><p></p>
    <a href="#"  style="line-height: 30px;color:rgba(142,142,143,0.97); " id="goToTop"><i class="glyphicon glyphicon-plane" style="font-size: 14px;padding: 5px;"></i>
        返回顶部</a>
   <!-- <h4 class="container"><b>BY车神</b></h4>
    <ul class="list-unstyled gradePaiHang">
        <li id="usernamePaiHang"><span >姓名</span> </li>
        <li id="gradePaiHang"> 分数</span></li>
    </ul>-->
    <div class="weixinQr hidden" style="position: absolute;top:50px;left:-120px; ">
        <b href="#" class="text-center"><img src="images/weixin.jpg" width="120px;">
            <p style="font-size: 12px;color: rgba(142,142,143,0.97); ">扫一扫，加我微信</p></b>
    </div>
    <div class="weiboQr hidden" style="position: absolute;top:80px;left:-120px; ">
        <b href="#" class="text-center"><img src="images/weibo.png" width="110px;">
            <p style="font-size: 12px;color: rgba(142,142,143,0.97); ">扫一扫，加我微博</p></b>
    </div>
</div>
</body>
<script type="text/javascript">
    $(function () {

        /**
         * 获取当前项目的路径
         * http://localhost:8083/proj
         */
        function getRootPath(){
            //获取当前网址，如： http://localhost:8083/proj/meun.jsp
            var curWwwPath = window.document.location.href;
            //获取主机地址之后的目录，如： proj/meun.jsp
            var pathName = window.document.location.pathname;
            var pos = curWwwPath.indexOf(pathName);
            //获取主机地址，如： http://localhost:8083
            var localhostPath = curWwwPath.substring(0, pos);
            //获取带"/"的项目名，如：/proj
            var projectName = pathName.substring(0, pathName.substr(1).indexOf('/')+1);
            return(localhostPath + projectName);
        }
        function getRootPath_dc() {
            var pathName = window.location.pathname.substring(1);
            var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
            if (webName == "") {
                return window.location.protocol + '//' + window.location.host;
            }
            else {
                return window.location.protocol + '//' + window.location.host + '/' + webName;
            }
        }

        //返回顶部
        $('#goToTop').click(function(){
            if(scrollTop>0){
                $('html ,body').animate({scrollTop: 0}, 300);
                return false;
            }
        });
        //生成二维码
        qrcode(getRootPath_dc());
        function  qrcode(e){

            $('#qrcode').qrcode({
                render : "canvas",  //设置渲染方式:table和canvas，使用canvas方式性能相对来说比较好
                width: 80,   //默认宽度
                height: 80, //默认高度
                typeNumber: -1,   //计算模式一般默认为-1
                correctLevel: 2, //二维码纠错级别
                background: "#ffffff",  //背景颜色
                foreground: "#000000",  //二维码颜色
                text: e, //二维码内容：可以直接填一个网址
            });
        }

        //获取当年
        var now = new Date();
        var time = now.getFullYear()
        $(".time").text(time);
        //用户未登录，隐藏错题
        $(".wrongItem").hide();
        //申明localstorage
        var storage = window.localStorage;
        //从localstorage获得用户信息
        $(".usernamedisplay").text(storage.getItem("username"));
        //刷新当前用户
        setInterval(function () {
            displayuser();
        }, 1000);

        //登陆成功后隐藏登录注册按钮
        function displayuser() {
            a = $(".usernamedisplay").text();
            if (a != "") {
                /* $(".displaylogin").css('display', 'none');
                 $(".nowuser").css('display', 'block');*/
                $(".wrongItem").fadeIn(1000);
                $(".displaylogin").fadeOut(1000);
                $(".nowuser").fadeIn(2000);
            }
        }


        /* $.Pop('',{
             Title:"提示信息",//标题
             Close:true,//是否显示关闭按钮 true(开)/false(关)
             Animation:"layerFadeIn",// 默认动画
             BoxBg:true, // 是否显示遮罩背景层 true(开)/false(关)
             BoxDrag:true, // 是否可以移动弹出层 true(开)/false(关)
             BoxBgopacity:0.6, // 遮罩层的透明度 0-1 0完全透明1完全黑暗
             ZIndex:99999, // 弹出层的cssz-index属性
             Class:false, // 是否叠加css样式
         });*/
        //登录
        $("#userLogin").on("click", function () {
            $.ajax({
                url: "/login",//url
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                data: {username: $("#username").val(), password: $("#password").val()},
                success: function (res) {
                    storage.setItem("username", res.username);
                    storage.setItem("id", res.id);
                    storage.setItem("type", res.type);
                    $.Pop('登录成功！', 'alert', function () {
                        window.location.reload()
                    })
                },
                error: function () {
                    // $.Pop('登录失败',{Animation:'slideFromTop',Title:"提示信息"});
                    $.Pop('<h5>登录失败,请重新登录</h5>', 'alert', function () {})
                }
            });
        });

        //注册
        $("#userRegister").on("click", function () {
            var myreg = /[^\s]/;
            var myreg2 = /\w{5,17}$/;
            //名称不能为空
            if (!myreg.test($("#rusername").val())) {
                $.Pro('用户名不能为空', {BoxBgopacity: 1});
                $("#rusername").focus();
                return false;
            }

             if (!myreg2.test($("#rpassword").val())) {
                $.Pro('请输入6~18密码', {BoxBgopacity: 1});
                $("#rpassword").focus();
                 return false;
            }
              if(!myreg.test($("#YanZhengMa").val())){
                 $.Pro('验证码不能为空', {BoxBgopacity: 1});
                  return false;
             }
              else if( $("#yanzhengma-hidden").val()!= $("#YanZhengMa").val()){
                  $.Pro('验证码错误', {BoxBgopacity: 1});
                  return false;
            }
            else {
                    $.ajax({
                        url: "/register",
                        type: "POST",
                        dataType: "json",
                        data: {username: $("#rusername").val(), password: $("#rpassword").val()},
                        success: function (res) {
                            storage.setItem("username", res.username);
                            storage.setItem("id", res.id);
                            storage.setItem("type", res.type);
                            $.Pop('<h5>注册成功</h5>', 'alert', function () {
                                window.location.reload()
                            });
                        }, error: function () {
                            $.Pop('<h5>注册失败,请重新注册</h5>', 'alert', function () {
                                window.location.reload()
                            });
                        }

                    });
            }
        });
        //获取验证码

        var InterValObj; //timer变量，控制时间
        var count = 60; //间隔函数，1秒执行
        var curCount;//当前剩余秒数
        $("#GetYanZhengMa").on("click",function () {
            //校验邮箱
            var email = $("#remail").val();
            if(!email.match(/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/)){
                // alert("邮箱格式不正确！请重新输入");
                $.Pro('邮箱格式不正确！请重新输入', {BoxBgopacity: 1});
                // return false;
            }else{
            // 设置button效果，开始计时
            curCount = count;
            document.getElementById("GetYanZhengMa").setAttribute("disabled","true" );//设置按钮为禁用状态
            document.getElementById("GetYanZhengMa").value=curCount + "秒后重获";//更改按钮文字
            InterValObj = window.setInterval(SetRemainTime, 1000); // 启动计时器timer处理函数，1秒执行一次
            var Num="";
            for(var i=0;i<6;i++)
            {
                Num+=Math.floor(Math.random()*10);
            }
            $.ajax({
                url:'getEamil',
                type:'post',
                dataType:'json',
                data:{to:$('#remail').val(),subject:"邮箱验证",content:"您好 "+$('#remail').val()+"！" +
                        "\n" +
                        "欢迎注册BY一考通，请将验证码填写到注册页面。\n验证码为:"+Num},
                success:function (res) {
                    if(res==true){
                        $("#yanzhengma-hidden").val(Num);
                    }
                }
            })
            }
        });

//timer处理函数
        function SetRemainTime() {
            if (curCount == 0) {//超时重新获取验证码
                window.clearInterval(InterValObj);// 停止计时器
                document.getElementById("GetYanZhengMa").removeAttribute("disabled");//移除禁用状态改为可用
                document.getElementById("GetYanZhengMa").value="重获验证码";
            }else {
                curCount--;
                document.getElementById("GetYanZhengMa").value=curCount + "秒后重获";
            }
        }
        //退出登录
        $("#loginOut").on("click", function () {
            localStorage.removeItem("username");
            localStorage.removeItem("id");
            localStorage.removeItem("type");
            window.location.reload(); //刷新当前页面
        });
        //显示\隐藏题库
        itemdisplay();

        function itemdisplay() {
            if (storage.getItem("type") == 1) {
                $(".itemdisplay").fadeIn(2000);
            }
        }
        // orderByUser();
        //排行orderByUser
        function orderByUser() {
            var html = "";
            $.ajax({
                url:'orderByUser',
                type:'post',
                dataType:'json',
                success:function (res) {
                    if(res.length>0){
                        for(var i=0;i<res.length;i++){
                            console.log(res[i].username);
                            /*$("#usernamePaiHang").html(res[i].username);
                            $("#gradePaiHang").html(res[i].grade);*/
                            html += "<li class=''>";
                            html += "<span>" +"姓名:"+ res[i].username + "</span>";
                            html += "<span>" +"成绩:"+res[i].grade+ "</span>";
                            html += "</li>";
                        }
                        $(".gradePaiHang").html(html);
                    }else{
                        $(".gradePaiHang").hide();
                    }
                }
            })
        }
        //判断用户是否存在
        $("#rusername").on('keyup',function () {
            $("#iusername").html("");
        })
        $("#rusername").on('blur',function () {
            if($("#rusername").val()==""){

            }else{
                $.ajax({
                    url:'queryUserByUsername',
                    type:'post',
                    dataType:'json',
                    data:{username:$('#rusername').val()},
                    success:function (res) {
                        if(res!=0){
                            $("#iusername").html("<span style=\"color: red\">用户名已存在</span>");
                            $("#rusername").focus();
                        }else{
                            $("#iusername").html("<span style=\"color: green\">用户名可以使用</span>");
                        }
                    }
                })
            }

        })

        //enter提交登录、注册
        $(document).keypress(function(e) {
            // 回车键事件
            if(e.which == 13) {
                // jQuery(".confirmButton").click();
                if($("#username").val()!=''){
                    jQuery("#userLogin").click();
                }
                else if($("#rusername").val()!=''){
                    jQuery("#userRegister").click();
                }
            }
        });

        //微信
        $(".weixin").hover(function () {
           $(".weixinQr").removeClass("hidden");
        },function () {
            $(".weixinQr").addClass("hidden");
        })
        //微博
        $(".weibo").hover(function () {
            $(".weiboQr").removeClass("hidden");
        },function () {
            $(".weiboQr").addClass("hidden");
        })
    });

    // 扫码考试框
    $(document).ready(function(){
        $(".fixediv a").click(function(){
            $(".fixediv").fadeOut(400);
        });
        $(".fixediv").floatadv();
    });
    jQuery.fn.floatadv = function(loaded) {
        var obj = this;
        body_height = parseInt($(window).height());
        block_height = parseInt(obj.height());
        top_position = parseInt((body_height/2) - (block_height/2) + $(window).scrollTop());
        if (body_height<block_height) { top_position = 0 + $(window).scrollTop(); };
        if(!loaded) {
            obj.css({'position': 'absolute'});
            obj.css({ 'top': top_position });
            $(window).bind('resize', function() {
                obj.floatadv(!loaded);
            });
            $(window).bind('scroll', function() {
                obj.floatadv(!loaded);
            });
        } else {
            obj.stop();
            obj.css({'position': 'absolute'});
            obj.animate({ 'top': top_position }, 400, 'linear');
        }
    }
</script>
</html>